<?php 
get_header();
$categories = get_the_category();


$app_version = get_post_meta($post->ID, "version", true);
$app_type = get_post_meta($post->ID, "type", true);
$app_create_time = get_post_meta($post->ID, "create_time", true);
$app_auth = get_post_meta($post->ID, "auth", true);
$app_language = get_post_meta($post->ID, "language", true);
$app_platform = get_post_meta($post->ID, "platform", true);
?>
<div class="wrapper">
	<div class="inner">
		<?php get_sidebar();?>
		<main class="main appbox">
			<div class="boxtop">
				<h2><?php echo $categories[0]->cat_name;?></h2>
				<div class="breadcrumb">
					<?php get_breadcrumbs();?>
				</div>
			</div>
			<?php if (have_posts()) : ?>
			<?php while (have_posts()) : the_post(); ?>
			<article class="apppage">
				<div class="appinfo">
					<div class="left">
						<figure class="icon">
							<img src="<?php get_template_part('functions/thumbnail');?>" alt="<?php the_title();?>"/>
						</figure>
					</div>
					<div class="middle">
						<h1 class="title"><?php the_title();?></h1>
						<div class="meta">
							<span><i>软件分类：</i><?php the_category(' , '); ?></span>
							<?php if ($app_version): ?>
                                <span><i>版本：</i><?php echo $app_version?></span>
							<?php endif;?>
							<?php if (false): ?>
                                <span><i>软件授权：</i><?php echo $app_auth?></span>
							<?php endif;?>
							<?php if ($app_type): ?>
                                <span><i>软件类型：</i><?php echo $app_type?></span>
							<?php endif;?>
							<?php if ($app_language): ?>
                                <span><i>软件语言：</i><?php echo $app_language?></span>
							<?php endif;?>
							<?php if ($app_create_time): ?>
                                <span><i>更新时间：</i><?php echo $app_create_time?></span>
							<?php endif;?>
							<?php if ($app_platform): ?>
                                <span><i>应用平台：</i><?php echo $app_platform?></span>
							<?php endif;?>
							<?php if(get_post_meta($post->ID, "size", true)){?>
							    <span><i>大小：</i><?php echo get_post_meta($post->ID, "size", true);?></span>
							<?php } ?>
							<span><i>热度：</i><?php if(function_exists('the_views')) { the_views(); }else{setPostViews(get_the_ID()); echo getPostViews(get_the_ID());} ?></span>
							<span><i>点评：</i><?php comments_number('0','1','%'); ?></span>
						</div>
<!--						<div class="date">-->
<!--							<em>发布：</em><time datetime="--><?php //the_time('Y-m-d');?><!--">--><?php //the_time('Y-m-d');?><!--</time>-->
<!--						</div>-->
						<div class="support">
							<em>支持：</em>
							<?php if(get_post_meta($post->ID, "android", true)){?>
							<span class="and"><i></i></span>
							<?php } ?>
							<?php if(get_post_meta($post->ID, "ios", true)){?>
							<span class="ios"><i></i></span>
							<?php } ?>
						</div>
						<?php the_tags('<div class="apptags"><span>关键词：</span><ul><li>','</li><li>','</li></ul></div>');?>						
					</div>
					<div class="right">
						<?php if(get_post_meta($post->ID, "ios", true)){?>
						<div class="btn iphone">
							<div class="canvas">
								<div id="ios" class="qr"></div>
							</div>
							<a rel="nofollow" href="<?php echo get_post_meta($post->ID, "ios", true);?>" title="直接下载" target="_blank">苹果下载</a>								
							<script type="text/javascript">
							new QRCode(document.getElementById('ios'), '<?php echo get_post_meta($post->ID, "ios", true);?>');
							</script>							
						</div>
						<?php } ?>
						<?php if(get_post_meta($post->ID, "android", true)){?>
						<div class="btn android">
							<div class="canvas">
								<div id="android" class="qr"></div>
							</div>
							<a rel="nofollow" href="<?php echo get_post_meta($post->ID, "android", true);?>" title="直接下载" target="_blank">安卓下载</a>
							<script type="text/javascript">
							new QRCode(document.getElementById('android'), '<?php echo get_post_meta($post->ID, "android", true);?>');
							</script>
						</div>
						<?php } ?>
					</div>
					<div class="clear"></div>
				</div>
				<?php 
				if(get_post_meta($post->ID,'screenshot',true)){
					$gallery = get_post_meta($post->ID,'screenshot',true);	
				?>
				<section class="appscreen">
					<h2 class="apptitle">APP截图</h2>
					<div class="screenlist">
						<div id="screen">
							<?php foreach($gallery  as $screenshot){?>
							<div class="item">
								<figure class="pic">
									<a title="<?php the_title();?>" href="<?php echo wp_get_attachment_image_src( $screenshot, 'full')[0];?>">
									<?php echo wp_get_attachment_image( $screenshot, 'full');?>
									</a>
								</figure>
							</div>
							<?php } ?>
						</div>
						<div class="load"></div>
					</div>
				</section>
				<?php } ?>
				<section class="content">
					<h2 class="apptitle">应用介绍</h2>
					<?php if(!empty($boke8['postStart'])){?>
					<div class="hmdiv">
						<?php echo htmlspecialchars_decode($boke8['postStart']);?>
					</div>
					<?php } ?>
					<div class="entry">
						<?php the_content();?>
					</div>
				</section>
				<section class="relatedapp">
					<h3 class="posttitle">相关应用</h3>
					<ul>
						<?php 
						$posts = get_posts('numberposts=10&post_status=publish&exclude='.get_the_ID().'&category='. $categories[0]->term_id);
						if($posts){	
							foreach( $posts as $post ) : setup_postdata( $post );
						?>
						<li>
							<figure class="icon">
								<a href="<?php the_permalink(); ?>" target="_blank" title="<?php the_title();?>"><img src="<?php get_template_part('functions/thumbnail');?>" alt="<?php the_title();?>"/></a>
							</figure>
							<p><a href="<?php the_permalink(); ?>" target="_blank" title="<?php the_title();?>"><?php the_title();?></a></p>
						</li>
						<?php endforeach; } wp_reset_postdata();?>
					</ul>
				</section>
				<?php if (comments_open() ) { comments_template('',true); }?>
			</article>
			<?php endwhile; ?>		
			<?php else : ?>
			<div class="post">
				<p>对不起！该页面尚未添加内容，请先浏览其它网页！</p>
			</div>
			<?php endif;?>			
		</main>
	</div>
</div>
<?php get_footer();?>